import Vue from 'vue'
import Router from 'vue-router'
import MyFilter from '@/pages/lux-filter.vue'
import MyLog from '@/pages/lux-in.vue'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'MyLog',
      component: MyLog
    },
    {
      path: '/filter',
      name: 'MyFilter',
      component: MyFilter
    }
  ]
})

router.beforeEach((to, from, next) => {
  let access = Vue.prototype.access
  if (to.name === 'MyLog') {
    next()
  } else if (to.name === 'MyFilter' && access) {
    next()
  } else {
    next('/')
  }
})

export default router
